class Solution:
    def nextGreaterElement(self, nums1, nums2):
        l1 = len(nums1)
        l2 = len(nums2)

        res = [-1] * l1
        for i in range(l1):
            n1 = nums1[i]
            for j in range(i + 1, l2):
                if nums2[j] > n1:
                    res[i] = nums2[j]
                    break

        return res

s = Solution()
print(s.nextGreaterElement([4,1,2], [1,3,4,2]))
print(s.nextGreaterElement([4,1,2], [1,2,3,4]))

